package com.atguigu.srb.core.controller.api;


import com.atguigu.common.result.R;
import com.atguigu.common.utils.JwtUtils;
import com.atguigu.srb.core.service.IntegralGradeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;

/**
 * <p>
 * 积分等级表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-09-13
 */
@RestController
@RequestMapping("/api/core/integralGrade")
public class ApiIntegralGradeController {
    @Resource
    IntegralGradeService integralGradeService;

    @GetMapping("/getBorrowAmountByUserId")
    public R getBorrowAmountByUserId(HttpServletRequest request){
        String token = request.getHeader("token");
        Long userId = JwtUtils.getUserId(token);
       BigDecimal borrowAmount = integralGradeService.getBorrowAmountByUserId(userId);
       return R.ok().data("borrowAmount",borrowAmount);
    }

}

